//
//  CourseListCellHeaderView.m
//  xpkc
//
//  Created by TopSageOSX on 14/11/1.
//  Copyright (c) 2014年 wanmeizty. All rights reserved.
//

#import "CourseListCellHeaderView.h"

@implementation CourseListCellHeaderView{
    UIView *bgView;
    UILabel *pointLabel;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
- (id)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        //
        [self creatHeaderView];
    }
    return self;
}
/**
 *  创建头部视图
 */
- (void)creatHeaderView{
    self.backgroundColor = [UIColor colorWithRed:0.98 green:0.98 blue:0.98 alpha:1];
    bgView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 80)];
    self.chapter = [[UILabel alloc]initWithFrame:CGRectMake(40, isPad?10:0, SCREEN_WIDTH-40, 40)];
    self.headBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    self.headBtn.frame = CGRectMake(0, 0, SCREEN_WIDTH-40, 40);
    self.line = [[UILabel alloc]init];
    self.line.layer.borderWidth = 1;
    self.line.layer.borderColor = GreenColor.CGColor;
    pointLabel = [[UILabel alloc]init];
    if (isPad) {
        UIView *point = [[UIView alloc]initWithFrame:CGRectMake(10, 20, 20, 20)];
        point.userInteractionEnabled = NO;
//        point.layer.cornerRadius = 10;
//        point.backgroundColor = [UIColor blueColor];
        self.line.frame = CGRectMake(20, 37, 1, 10);
        [bgView addSubview:self.line];
        [self.headBtn addSubview:point];
        pointLabel.frame = CGRectMake(0.5, 0, 20, 20);
        [point addSubview:pointLabel];
    }else{
        UIView *point = [[UIView alloc]initWithFrame:CGRectMake(10, 10, 20, 20)];
        point.userInteractionEnabled = NO;
//        point.layer.cornerRadius = 10;
//        point.backgroundColor = [UIColor blueColor];
        self.line.frame = CGRectMake(20, 27, 1, 20);
        [bgView addSubview:self.line];
        [self.headBtn addSubview:point];
        pointLabel.frame = CGRectMake(0.5, 0, 20, 20);
        [point addSubview:pointLabel];
    }
    pointLabel.userInteractionEnabled = NO;
    pointLabel.text = @"○";
    pointLabel.font= [UIFont systemFontOfSize:17];
    pointLabel.textAlignment = NSTextAlignmentCenter;
    pointLabel.textColor = [UIColor orangeColor];
    [self.headBtn addSubview:self.chapter];
    bgView.backgroundColor = [UIColor clearColor];
    //分隔线
    UILabel *line = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 5)];
    line.backgroundColor = [UIColor whiteColor];
    [bgView addSubview:self.headBtn];
    [bgView addSubview:line];
    [self addSubview:bgView];
}
- (void)move:(NSInteger)mod{
    if (mod == 1) {
        bgView.frame = CGRectMake(38, 0, SCREEN_WIDTH, 40);
    }else{
        bgView.frame = CGRectMake(0, 0, SCREEN_WIDTH, 40);
    }
}
- (void)close:(BOOL)close{
    if (close) {
        //关
        CGRect frame = self.line.frame;
        frame.size.height = 0;
        self.line.frame = frame;
        pointLabel.textColor = GreenColor;
        pointLabel.text = @"●";
        pointLabel.font= [UIFont systemFontOfSize:33];
    }else{
        CGRect frame = self.line.frame;
        frame.size.height = isPad?23:13;
        self.line.frame = frame;
        pointLabel.textColor = GreenColor;
        pointLabel.text = @"○";
        pointLabel.font= [UIFont systemFontOfSize:17];
    }
}
@end
